package cn.monkey.family.server.domain.uc.user;

import cn.monkey.family.data.uc.role.RoleMapper;
import cn.monkey.family.data.uc.user.UserMapper;
import cn.monkey.family.server.domain.uc.role.RoleRepository;
import cn.monkey.family.server.domain.uc.user.role.UserRoleHandler;
import cn.monkey.family.server.domain.uc.user.role.UserRoleRepository;
import org.mapstruct.factory.Mappers;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

@Configuration
public class UserConfig {

    @Bean
    UserMapper userMapper() {
        return Mappers.getMapper(UserMapper.class);
    }

    @Bean
    UserRoleHandler userRoleHandler(RoleMapper roleMapper,
                                    UserRoleRepository userRoleRepository,
                                    RoleRepository roleRepository) {
        return new UserRoleHandler(roleMapper, userRoleRepository, roleRepository);
    }
}
